#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<assert.h>
#include<stdlib.h>

typedef char STdatetype;
typedef struct Stack {
	STdatetype* phead;
	int size;
	int capacity;
}ST;
void STDInit(ST* tmp) {
	assert(tmp);
	tmp->phead = NULL;
	tmp->capacity = tmp->size = 0;
}
void STDdestroy(ST* tmp) {
	assert(tmp);
	free(tmp->phead);
	tmp->phead = NULL;
	tmp->capacity = tmp->size = 0;
}
bool IsFull(ST* tmp) {
	if (tmp->size == tmp->capacity) {
		return true;
	}
	return false;
}
void push(ST* tmp, STdatetype date) {
	assert(tmp);
	if (IsFull(tmp)) {
		int newcapacity = tmp->capacity == 0 ? 4 : 2 * tmp->capacity;
		STdatetype* ptr = (STdatetype*)realloc(tmp->phead, newcapacity * sizeof(STdatetype));
		if (!ptr) {
			perror("push:relloc");
			return;
		}
		tmp->phead = ptr;
		tmp->capacity = newcapacity;
	}
	tmp->phead[tmp->size++] = date;
}
void pop(ST* tmp) {
	assert(tmp);
	if (tmp->size != 0)
		tmp->size--;
	else {
		perror("pop");
	}
}
bool isValid(char* s) {
	size_t len = strlen(s);
	if (len % 2) {
		return false;
	}
	ST stack;
	STDInit(&stack);
	for (int i = 0; i < len; i++) {
		if (s[i] == '(' || s[i] == '[' || s[i] == '{') {
			push(&stack, s[i]);
		}
		if (s[i] == ')' || s[i] == ']' || s[i] == '}') {
			if (stack.size == 0) {
				STDdestroy(&stack);
				return false;
			}
			if (stack.phead[stack.size - 1] == '(' && s[i] == ')') {
				pop(&stack);
			}
			else if (stack.phead[stack.size - 1] == '[' && s[i] == ']') {
				pop(&stack);
			}
			else if (stack.phead[stack.size - 1] == '{' && s[i] == '}') {
				pop(&stack);
			}
			else {
				return false;
			}
		}
	}
	if (stack.size == 0) {
		STDdestroy(&stack);
		return true;
	}
	else {
		STDdestroy(&stack);
		return false;
	}
}
int main()
{
	char arr[1000];
	scanf("%s", arr);
	if (isValid(arr)) {
		printf("true");
	}
	else {
		printf("false");
	}
	return 0;
}